/*
 * Created on 26/02/2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.potiorb.orb;

import org.potiorb.orb.invoke.Invoker;
import org.potiorb.orb.marshal.Marshaler;
import org.potiorb.orb.poa.POA;
import org.potiorb.orb.portable.ObjectImpl;
import org.potiorb.orb.portable.ObjectRef;
import org.potiorb.orb.receive.Receiver;


public class ORBImpl extends ORB {

      protected static Invoker m_Invoker;
      protected static Marshaler m_Marshaler;
      protected static Receiver m_Receiver;
      protected static POA rootpoa;

	public ORBImpl(){
        m_Invoker = new Invoker();
		m_Marshaler = new Marshaler();
		rootpoa = new POA(this);
		m_Receiver = new Receiver(rootpoa);
	}

	public Object string_to_object(String str) {
		ObjectImpl objimpl = new ObjectImpl();
		ObjectRef refStr = new ObjectRef();
		
        refStr.setHost("127.0.0.1");
		refStr.setPort("11000");
		refStr.setKeyobject(str);
		
		refStr.setHost("127.0.0.1");
		refStr.setPort("11000");
		refStr.setKeyobject(str);

		refStr.setOrb(this);

		objimpl._set_delegate(refStr);
		return objimpl;
	}

	public String object_to_string(Object obj) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see org.potiorb.orb.ORB#run()
	 */
	public void run() {
		m_Receiver.HandleEvents(11000);
	}

	/* (non-Javadoc)
	 * @see org.potiorb.orb.ORB#shutdown(boolean)
	 */
	public void shutdown(boolean wait_for_completion) {
		// TODO Auto-generated method stub

	}
	/**
	 * @return Returns the m_Invoker.
	 */
	public Invoker getInvoker() {
		return m_Invoker;
	}

	/**
	 * @return Returns the m_Marshaler.
	 */
	public Marshaler getMarshaler() {
		return m_Marshaler;
	}

	/**
	 * @return Returns the m_Receiver.
	 */
	public Receiver getReceiver() {
		return m_Receiver;
	}

	public POA getRootPOA()
	{
		if( rootpoa == null )
		{
			rootpoa = new POA(this);
		}
		return rootpoa;
	}



	public java.lang.Object resolve_initial_references(String identifier)
	{
			if( identifier.equals("RootPOA") )
			{
				return (java.lang.Object)getRootPOA();
			}
			return null;
	}


}
